#include<iostream>
#include<string>
#include<jsoncpp/json/json.h>

class Request
{
public:
    Request(int x,int y,char oper)
        :_x(x)
        ,_y(y)
        ,_oper(oper)
    {

    }

    Request()
    {}

    bool Serialize(std::string *out)
    {
        Json::Value root;
        root["x"]=_x;
        root["y"]=_y;
        root["oper"]=_oper;
        Json::FastWriter writer;
        //Json::StyledWriter writer;
        std::string s=writer.write(root);

        *out=s;
        return 1;
    }

    void Deserialize(const std::string &in)
    {
        Json::Value root;
        Json::Reader reader;
        bool res=reader.parse(in,root);

        _x=root["x"].asInt();
        _y=root["y"].asInt();
        _oper=root["oper"].asInt();
    }

    void Print()
    {
        std::cout<<_x<<std::endl;
        std::cout<<_y<<std::endl;
        std::cout<<_oper<<std::endl;
    }

    ~Request()
    {}

private:
    int _x;
    int _y;
    char _oper;
};

int main()
{
    // Request req(111,222,'+');
    // std::string s;
    // req.Serialize(&s);
    // std::cout<<s<<std::endl;

    std::string s="{\"oper\":43,\"x\":111,\"y\":222}";
    Request req;
    req.Deserialize(s);
    req.Print();
}